package com.world.rickcloudendpoint.models.vo;

import com.world.rickcloudendpoint.common.utils.DateTimeUtils;
import com.world.rickcloudendpoint.common.utils.NumberUtils;
import com.world.rickcloudendpoint.models.mongo.ASignalDoc;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId;

/**
 * @description: A信号视图
 * @author: jlsong
 * @date: 2022/01/22 20:51:46
 * @version: 1.0
 */
@Data
@ApiModel(value = "aSignalVO", description = "A信号体")
public class ASignalVO {
    @ApiModelProperty("数据集ID")
    private String id;

    @ApiModelProperty("数据类型编号")
    private String typeSerial;

    @ApiModelProperty("数据所属实验号")
    private String experimentNo;

    @ApiModelProperty("报文发送时间，单位：ms")
    private long sendTime;

    @ApiModelProperty("站号，来源")
    private String stationNo;

    @ApiModelProperty("批号")
    private String batchNo;

    @ApiModelProperty("经度,，.000001，单位：度")
    private double lon;

    @ApiModelProperty("纬度，.000001，单位：度")
    private double lat;

    @ApiModelProperty("高度，0.01，单位：米")
    private double alt;

    @ApiModelProperty("航速，0.01，单位：km/h")
    private double speed;

    @ApiModelProperty("航向，10.01，单位：度")
    private double heading;

    @ApiModelProperty("目标种类")
    private String targetType;

    @ApiModelProperty("目标属性")
    private String targetAttr;

    @ApiModelProperty("目标识别号")
    private String targetSerial;

    public ASignalDoc toDoc() {
        ASignalDoc doc = new ASignalDoc();
        if (!StringUtils.isBlank(this.id)) {
            doc.set_id(new ObjectId(this.id));
        }
        DateTimeUtils.YmdHmsMillis yhm = DateTimeUtils.timeStampToYmdHmsMillis(this.sendTime);
        doc.setSendYear(yhm.getYear());
        doc.setSendMonth((short) yhm.getMonth());
        doc.setSendDay((short) yhm.getDay());
        doc.setSendHour((short) yhm.getHour());
        doc.setSendMin((short) yhm.getMinute());
        doc.setSendSec((short) yhm.getSecond());

        doc.setLon(NumberUtils.doubleToLong(this.lon, 6));
        doc.setLat(NumberUtils.doubleToLong(this.lat, 6));
        doc.setAlt(NumberUtils.doubleToLong(this.alt, 2));
        doc.setSpeed(NumberUtils.doubleToLong(this.speed, 2));
        doc.setHeading(NumberUtils.doubleToLong(this.heading, 2));

        doc.setTypeSerial(this.typeSerial);
        doc.setExperimentNo(this.experimentNo);
        doc.setStationNo(this.stationNo);
        doc.setBatchNo(this.batchNo);
        doc.setTargetType(this.targetType);
        doc.setTargetAttr(this.targetAttr);
        doc.setTargetSerial(this.targetSerial);

        return doc;
    }
}
